<template>
  <div class="topNav">
    <div class="w">
      <div class="recommendItem" @click="itemClick(0)">
        <span :class="{ active: currentIndex === 0 }">推荐</span>
      </div>
      <div class="MVItem" @click="itemClick(1)">
        <span :class="{ active: currentIndex === 1 }">MV</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "TopNav",
  data() {
    return {
      currentIndex: 0,
    };
  },
  methods: {
    itemClick(index) {
      this.currentIndex = index;
      this.$emit("navClick", index);
    },
  },
};
</script>

<style lang="scss" scoped>
.topNav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background-color: #f5f5f5;
  .w {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    height: 3rem;
    div {
      height: 3rem;
      line-height: 3rem;
      margin-right: 2rem;
      font-size: 1rem;
      cursor: pointer;
      span {
        font-size: 1rem;
      }
      span.active {
        font-size: 1.5rem;
        font-weight: 700;
        color: #1a1a1a;
        border-bottom: 0.2rem solid #22d59c;
      }
    }
  }
}
</style>